package com.sgam.mf.dao.entity;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.sgam.mf.dao.GenericDAOImpl;
import com.sgam.mf.domain.entity.ContractPayments;
import com.sgam.mf.domain.entity.Contracts;
import com.sgam.mf.helper.ProxyCurrentUser;

@Repository
public class ContractPaymentsDAOImpl extends GenericDAOImpl<ContractPayments> implements ContractPaymentsDAO{
	
	protected final Logger log = Logger.getLogger(getClass());
	
	@SuppressWarnings("unchecked")
	public List<ContractPayments> list(ProxyCurrentUser user, Integer pPersonalId, Integer pPartnerId) {
		log.debug("***********************************************");
		log.debug("ContractPaymentsDAOImpl - list");
		log.debug(user.toString());
		//log.debug(listType);
		log.debug("***********************************************");
		String whereForSecurity = "";
		
		
		
//		if (user.getUserRoleId() == 0 || user.getUserRoleId() == 1){ //If user is Administrator or Manager
			whereForSecurity = " where 1=1 ";
//		}
		
//		if (user.getUserRoleId() == 2){ //If user	Consultant OC
//			whereForSecurity = " where ref_status_fk <> 0 ";
//		}	
		
//		if (user.getUserRoleId() == 2){ //If user	Consultant OC
//			whereForSecurity = " where respons_consultant_fk = " + user.getUserId() + " ";
//		}	
		
//		if (user.getUserRoleId() == 3){ //If user	Personal 
//			whereForSecurity = " where ref_status_fk not in (0 , 1)  and respons_personal_fk = " + user.getUserId() + " ";
//		}		
		
//		if (user.getUserRoleId() == 4){ //If user	Consultant OT 
//			whereForSecurity = " where respons_consultant_fk = " + user.getUserId() + " ";
//		}	
//		
//		if(listType==1) {
//			whereForSecurity = whereForSecurity + " and contract_no != '' "; 
//		}
		
		List<ContractPayments>  result = getCurrentSession().createQuery("from contracts c left outer join ContractPayments cp on (c.id=cp.contractIdFk) " ).list();
		return result;
	}

}

	
